<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/5/24 0024
 * Time: 下午 3:03
 */

namespace App\Model;


/**
 * 游戏注单信息入库
 * @author Administrator
 *
 */
class GameOrder extends BaseModel
{
    protected $userId;          //用户ID
    protected $userToken;       //用户Token
    protected $userName;        //用户姓名
    protected $face;            //用户头像
    protected $isSpeak;         //用户是否能发言
    protected $extends;         //附加用户信息
    protected $group;           //
    protected $clientIp;        //IP
    //DB对象
    public $tableName = 'qc_games_orders';
    public $tongjiTabName = 'qc_user_tongji';
    public $recodeTabName = 'qc_points_record';
    public function __construct(){
        parent::__construct();
    }
    
    
    /**
     * 获取用户信息
     */
    public function getOrder($gameNo){
        $result = $this->getDb()->where('gameNo',$gameNo)->getOne($this->tableName);
        $this->clearPool(); //释放连接池
        return $result;
    }
    //获取单个信息
    public function getOneOrderFields($userId,$field) {
        if(!$userId || intval($userId)<= 0) return false ;
        $result = $this->getDb()->where('uid',$userId)->getOne($this->tableName,$field);
        $this->clearPool(); //释放连接池
        if(isset($result) && !empty($result)){
            return isset($result[$field]) ? $result[$field] : FALSE ;
        }
    }
    
    /**
     * 添加新订单数据
     * @param array $orderList
     * @return number|unknown 受影响条数
     */
    public function addOrder($orderList){
        if(!$orderList) return 0;
        $result = $this->getDb()->insertMulti($this->tableName, $orderList); 
        //$this->clearPool(); //释放连接池
        return $result;
    }
    
    
    
    /**
     * 修改订单信息；
     * @param boolean $user
     */
    public function editUserOrder($userId) {
        //$this->connect_db ->setQueryOption('FOR UPDATE') ->  get($this->tableName) ;  //加锁的操作查询；
        //return $this->connect_db ->where($field, $roomId)->update($this->tbRoomDisplayName, $editdata) ;
    }
    
    
}



